/**
 * lecture_create 页面 js
 */
$(function(){
	_label();
});

/**
 * 讲座标签
 */
function _label(){
	$.ajax({
		url:'../dictionary/lectureLabel.do',
		dataType:'json',
		type: "post",
		success:function(data){
			var html="";
			for(var i=0;i<data.data.length;i++){
				html += "<label><input id=\"2001\" name=\"label\" type=\"checkbox\" value=\""+data.data[i]+"\" onClick=\"check_count('xingge', this, 3)\">"+data.data[i]+"</label>";
			}
			$('#edit_xingge').html(html); 
		}
		
	});
}

/**
 * 擅长领域标签
 */
function _expertiseLabel(){
	$.ajax({
		url:'<%=basePath%>dictionary/expertiseLabel.do',
		dataType:'json',
		type: "post",
		success:function(data){
			var html="";
			for(var i=0;i<data.data.length;i++){
				html += "<label><input id=\"1101\" name=\"label\" type=\"checkbox\" value=\""+data.data[i]+"\" onClick=\"check_count('xingge', this, 3)\">"+data.data[i]+"</label>";
			}
			$('#edit_xingge1').html(html); 
		}
		
	});
}

function search(tid) {
	var readonly=$('#dakaID').attr('readonly');//判断是否已经绑定大咖
	if(readonly==null ||readonly==""){//没有绑定 可以搜索
	    //非空校验
		if(tid==null || tid==""){
			//为空, 关闭 列表div
			document.getElementById('search').style.display = "none";
			alert("请先输入大咖的名字 !");
		} else {
			// 不为空
			// 先清空div
			$("#searchTid").attr("value", "");
			$("#searchName").attr("value", "");
			$("#searchSex").attr("value", "");
			$("#searchEmployer").attr("value", "");
			$("#searchPosition").attr("value", "");
			$("#searchField").attr("value", "");
			$("#searchBrief").text("");
			$.ajax({
				type : 'post',
				url : '../lecture/getTalentDictionaryVo.do',
				data : {
					"tid":tid
				},
				success : function(a) {
					if(a==null || a==""){
	            		document.getElementById('search').style.display = "none";
	       				alert("没有该大咖,请重新输入 !");
	            	}else{
	            		document.getElementById('search').style.display = "block"; 
	            		/*  $("#search").show(); */
	            		$("#searchTid").attr("value",a.tid);
	            		$("#searchName").attr("value",a.name);
	            		$("#searchSex").attr("value",a.dicname);
	            		$("#searchEmployer").attr("value",a.employer);
	            		$("#searchPosition").attr("value",a.position);
	            		$("#searchField").attr("value",a.field);
	            		$("#searchBrief").text(a.brief);   
	            	}
				}
			})
		}
	}
}